package com.ekuaitu.kuaitu.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ekuaitu.kuaitu.R;
import com.ekuaitu.kuaitu.bean.SettlementDetailBean;
import com.ekuaitu.kuaitu.utils.TimeUtils;
import com.zhy.autolayout.utils.AutoUtils;

import java.text.DecimalFormat;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by CaoJing on 2016/10/5.
 */
public class YouhuiLvAdapter extends BaseAdapter {
    private List<SettlementDetailBean.AttachmentBean.ModelBean.SpecialModelListBean> mlist;
    private Context mContext;

    public YouhuiLvAdapter(List<SettlementDetailBean.AttachmentBean.ModelBean.SpecialModelListBean> list, Context context) {
        this.mlist = list;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return mlist != null ? mlist.size() : 0;
    }

    @Override
    public Object getItem(int i) {
        return mlist != null ? mlist.get(i) : null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_youhui_lv, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
            //对于listview，注意添加这一行，即可在item上使用高度
            AutoUtils.autoSize(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        SettlementDetailBean.AttachmentBean.ModelBean.SpecialModelListBean item = mlist.get(position);
        DecimalFormat df = new DecimalFormat("0.00");
        holder.orderCarRzyh.setText(item.getSpecialName());
        holder.orderCarRzyhmoney.setText("-" + df.format(item.getSubMoney()) + "元");
        return convertView;
    }


    static class ViewHolder {
        @BindView(R.id.order_car_rzyh)
        TextView orderCarRzyh;
        @BindView(R.id.order_car_rzyhmoney)
        TextView orderCarRzyhmoney;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}

